Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Object Creation and Deletion

Object creation and deletion is similar to object registration, except that the data being operated on is the instance data. The TQ3XObjectNewMethod method should initialize all data in the private data structure and allocate any memory needed to copy the data in. The TQ3XObjectDeleteMethod method should deallocate any data in the private data structure of the object.

TQ3XObjectNewMethod

The TQ3XObjectNewMethod function, returned by the kQ3XMethodTypeObjectNew method, initializes data in the object's private data structure and allocates the required memory.

#define kQ3XMethodTypeObjectNew Q3_METHOD_TYPE('n','e','w','o')
typedef TQ3Status (*TQ3XObjectNewMethod)(
                     TQ3Object    object,
                     void         *privateData,
                     void         *parameters);
object
An object.
privateData
Pointer to the object's private data.
parameters
Pointer to parameters to be passed.

DESCRIPTION

The TQ3XObjectNewMethod method should initialize all data in the private data structure (possibly with parameters) and allocate any memory needed to copy the data in. If instanceSize in the previous Q3ObjectHierarchy_RegisterClass call was nonzero, a TQ3ObjectNewMethod is required. If instanceSize was 0, the TQ3XObjectNewMethod method is never called.

TQ3XObjectDeleteMethod

The TQ3XObjectDeleteMethod function, which is returned by the kQ3XMethodTypeObjectDelete method, deallocates data in the object's private data structure.

#define kQ3XMethodTypeObjectDelete Q3_METHOD_TYPE('d','l','t','e')
 
typedef void (*TQ3XObjectDeleteMethod)(
TQ3Object    object, void         *privateData );
object
An object.
privateData
Pointer to the object's private data.

DESCRIPTION

The TQ3XObjectDeleteMethod method deallocates any data in the private data structure of the object. If instanceSize in the Q3ObjectHierarchy_RegisterClass call was nonzero, a TQ3XObjectDeleteMethod is required. If instanceSize was 0, the TQ3XObjectDeleteMethod method is never called.

TQ3XObjectDuplicateMethod

The TQ3XObjectDuplicateMethod function, which is returned by the kQ3XMethodTypeObjectDuplicate method, duplicates an object and copies its private instance data.

#define kQ3XMethodTypeObjectDuplicate Q3_METHOD_TYPE('d','u','p','l')
typedef TQ3Status (*TQ3XObjectDuplicateMethod)(
                     TQ3Object     fromObject,
                     const void    *fromPrivateData,
                     TQ3Object     toObject,
                     const void    *toPrivateData);
fromObject
Object to be copied.
fromPrivateData
Pointer to private data of object to be copied.
toObject
Object to be copied into.
toPrivateData
Pointer to private data of object to be copied into.

DESCRIPTION

The TQ3XObjectDuplicateMethod method should copy the private instance data from fromPrivateData to toPrivateData and return kQ3Success if sucessful. Otherwise, it should deallocate anything it has allocated, clean up its parent classes, and return kQ3Failure . TQ3XObjectDuplicateMethod is called in the same way as TQ3XObjectNewMethod and TQ3XObjectDeleteMethod .

EXAMPLE

TQ3Status Q3FooGroup_Duplicate(
    TQ3GroupObject              src,
    TFooGroupPrivate            *srcPriv,
    TQ3GroupObject              dst,
    TFooGroupPrivate            *dstPriv)
{
    *dstPriv = *srcPriv;
    return kQ3Success;
}

TQ3XObjectUnregisterMethod

The TQ3XObjectUnregisterMethod function, which is returned by the kQ3MethodTypeObjectUnregister method, removes a custom object class.

#define kQ3MethodTypeObjectUnregister Q3_METHOD_TYPE('u','n','r','g')
typedef TQ3Status (*TQ3XObjectUnregisterMethod)
                     (TQ3XObjectClass    objectClass);
objectClass
An object class.

DESCRIPTION

The TQ3XObjectUnregisterMethod function unregisters the custom object class specified by the objectClass parameter.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |